//
//  ZGSMineViewController.m
//  MapleLeaf
//
//  Created by dllo on 15/11/26.
//  Copyright © 2015年 AntennaBabyTeam. All rights reserved.
//

#import "ZGSMineViewController.h"
#import "ZGSArtleViewController.h"
@interface ZGSMineViewController ()<UITableViewDelegate, UITableViewDataSource>
@property(nonatomic, strong) UITableView *tableView;
@property(nonatomic, strong) UIImageView *headImageView;
@end

@implementation ZGSMineViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationController.navigationBar.hidden = YES;
    
    [self.tableView reloadData];
    
    
    [self createTableView];
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
    self.navigationController.navigationBar.hidden = YES;
    self.tabBarController.tabBar.hidden = NO;
}

- (void)createTableView{
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT) style:UITableViewStyleGrouped];
    self.tableView.backgroundColor = [UIColor colorWithRed:0.969f green:0.961f blue:0.973f alpha:1.00f];
    [self.view addSubview:self.tableView];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    
    [self.tableView registerClass:[ZGSMainCell class] forCellReuseIdentifier:@"TableViewCellReuse"];
}

#pragma mark -tableView协议方法
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 70;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 3;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    ZGSMainCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TableViewCellReuse"];
    
    if (indexPath.row == 0) {
        cell.leftImageView.image = [UIImage imageNamed:@"iconfont-icon111.png"];
        cell.rightImageView.image = [UIImage imageNamed:@"iconfont-tiaozhuan1.png"];
        cell.titleLabel.text = @"每日阅读";
    }
//    else if (indexPath.row == 1) {
//        cell.leftImageView.image = [UIImage imageNamed:@"iconfont-set.png"];
//        cell.rightImageView.image = [UIImage imageNamed:@"iconfont-tiaozhuan1.png"];
//        cell.titleLabel.text = @" ";
//    }
//    else if (indexPath.row == 2) {
//        cell.leftImageView.image = [UIImage imageNamed:@"iconfont-xiazai.png"];
//        cell.rightImageView.image = [UIImage imageNamed:@"iconfont-tiaozhuan1.png"];
//        cell.titleLabel.text = @"下载管理";
//    }
    
    else if (indexPath.row == 1) {
            cell.leftImageView.image = [UIImage imageNamed:@"iconfont-guanyuwomen.png"];
            cell.rightImageView.image = [UIImage imageNamed:@"iconfont-tiaozhuan1.png"];
            cell.titleLabel.text = @"关于我们";
        }
    else if (indexPath.row == 2) {
            cell.leftImageView.image = [UIImage imageNamed:@"iconfont-yijianfankui.png"];
            cell.rightImageView.image = [UIImage imageNamed:@"iconfont-tiaozhuan1.png"];
            cell.titleLabel.text = @"在线客服";
    }
    
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 250;
}


- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 250)];
    imageView.image = [UIImage imageNamed:@"head.jpg"];
    
    
    return imageView;
}



- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    if (indexPath.section == 0) {
        if (indexPath.row == 0) {
            ZGSArtleViewController *osVC = [[ZGSArtleViewController alloc] init];
                    osVC.hidesBottomBarWhenPushed = YES;
            [self.navigationController pushViewController:osVC animated:YES];
        }
//        if (indexPath.row == 1) {
//            ZGSOptionViewController *opVC = [[ZGSOptionViewController alloc] init];
//            [self.navigationController pushViewController:opVC animated:YES];
//        }
        if (indexPath.row == 2) {
            RCPublicServiceChatViewController *conversationVC = [[RCPublicServiceChatViewController alloc] init];
            conversationVC.conversationType = ConversationType_APPSERVICE;
            conversationVC.targetId = @"KEFU144945676295142";
            conversationVC.userName = @"枫叶岛客服";
            conversationVC.title = @"枫叶岛客服";
            [self.navigationController pushViewController:conversationVC animated:YES];
            self.navigationController.navigationBar.hidden = NO;
            self.tabBarController.tabBar.hidden = YES;
        }

    }
    
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}





- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
